<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>

		<link rel="stylesheet" href="${pageContext.request.contextPath}/main/css/amazeui.min.css">
		<link rel="stylesheet" href="${pageContext.request.contextPath}/main/css/admin.css">
		<link rel="stylesheet" href="${pageContext.request.contextPath}/main/css/app.css"> 
		<script src="${pageContext.request.contextPath}/client/js/layui.js"></script>
        <link rel="stylesheet" href="${pageContext.request.contextPath}/client/css/layui.css" />
		
	</head>

	<body>

		<div class="am-cf admin-main">
			<!-- content start -->
			<div class="admin-content">
				<div class="admin-content-body">
					<div class="am-cf am-padding am-padding-bottom-0">
						<div class="am-fl am-cf">
							<strong class="am-text-primary am-text-lg"> </strong><small>
								<i class="icon-home"></i> &gt; 首页 &gt; 维护白名单	</small>
						</div>
					</div>
					<hr>
					<div class="layui-container">
					    <form class="layui-form" method="post" action="/gongyinglian/AddWhiteListController" style="margin-top: 20px;">
					        <div class="layui-row">
					            <div class="layui-col-md6">
					                <h2>上游企业</h2>
					                <table class="layui-table" id="upstreamTable">
					                    <colgroup>
					                        <col width="150">
					                        <col width="200">
					                        <col>
					                    </colgroup>
					                    <thead>
					                    <tr>
					                        <th>企业ID</th>
					                        <th>企业名称</th>
					                        <th>&nbsp;</th>
					                    </tr>
					                    </thead>
					                    <tbody>
					                    <c:forEach items="${upChain}" var="ent">
					                        <tr>
					                            <td><input type="text" name="upstreamId" value="${ent.entNo}" class="layui-input" readonly></td>
					                            <td><input type="text" name="upstreamName" value="${ent.name}" class="layui-input" readonly></td>
					                            <td><button type="button" onclick="removeRow(this)" class="layui-btn layui-btn-danger">删除</button></td>
					                        </tr>
					                    </c:forEach>
					                    </tbody>
					                </table>
					                <button type="button" onclick="addRow('upstreamTable','upstream')" class="layui-btn">添加</button>
					            </div>
					            <div class="layui-col-md6">
					                <h2>下游企业</h2>
					                <table class="layui-table" id="downstreamTable">
					                    <colgroup>
					                        <col width="150">
					                        <col width="200">
					                        <col>
					                    </colgroup>
					                    <thead>
					                    <tr>
					                        <th>企业ID</th>
					                        <th>企业名称</th>
					                        <th>&nbsp;</th>
					                    </tr>
					                    </thead>
					                    <tbody>
					                    <c:forEach items="${downChain}" var="ent">
					                        <tr>
					                            <td><input type="text" name="downstreamId" value="${ent.entNo}" class="layui-input" readonly></td>
					                            <td><input type="text" name="downstreamName" value="${ent.name}" class="layui-input" readonly></td>
					                            <td><button type="button" onclick="removeRow(this)" class="layui-btn layui-btn-danger">删除</button></td>
					                        </tr>
					                    </c:forEach>
					                    </tbody>
					                </table>
					                <button type="button" onclick="addRow('downstreamTable','downstream')" class="layui-btn">添加</button>
					            </div>
					        </div>
					        <div class="layui-row">
					            <div class="layui-col-md12" style="text-align: center; margin-top: 20px;">
					                <button type="submit" class="layui-btn layui-btn-normal">提交</button>
					            </div>
					        </div>
					    </form>
					</div>
				<!-- content end -->
			</div>
		</div>
		<script>
	    function addRow(tableId, name) {
	        var table = document.getElementById(tableId);
	        var row = table.insertRow(-1);
	        var cell1 = row.insertCell(0);
	        var cell2 = row.insertCell(1);
	        var cell3 = row.insertCell(2);
	        cell1.innerHTML = "<input type='text' name='" + name + "Id' class='layui-input' />";
	        cell2.innerHTML = "<input type='text' name='" + name + "Name' class='layui-input' />";
	        cell3.innerHTML = "<button type='button' onclick='removeRow(this)' class='layui-btn layui-btn-danger'>删除</button>";
	    }

	    function removeRow(button) {
	        var row = button.parentNode.parentNode;
	        row.parentNode.removeChild(row);
	    }
        </script>
        <script>
		    // 使用JSTL或EL表达式获取请求是否成功的状态
		    var isRequestSuccess = ${isRequestSuccess};
		    var message = "${message}";
		    console.log(isRequestSuccess + ":" + message);
		
		    // 显示相应的提醒框
		    if (isRequestSuccess) {
		        alert(message);
		    } else {
		        alert(message);
		    }
		</script>

		<!--[if lt IE 9]>
<script src="js/jquery.min.js"></script>
<script src="js/modernizr.js"></script>
<script src="js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

		<!--[if (gte IE 9)|!(IE)]><!-->
		<script src="js/jquery-1.11.3.min.js"></script>
		<!--<![endif]-->
		<script type="text/javascript" src="js/plugs.js"></script>
	</body>

</html>